
////////////////////////////////////////////////////////////////////////////////////////////
// 文件名: SysParametersBLL.gen.cs
//
// 模块名称: SysParameters
//
// 作者: ZXF
//
// 历史记录（记录修改记录，修改文件后请添加修改记录，注明修改时间、修改人，修改内容）:
// 2013/1/22    ZXF    创建文件
////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Web.Mvc;
using Model;
using DAL;
using Common;

namespace BLL
{
    /// <summary>
    /// SysParameters表业务逻辑层
    /// </summary>
    public partial class SysParametersBLL: BaseBLL
    {
        public SysParametersBLL(LoginInfo info)
        {
            loginInfo = info;
        }
        const string RightCodeInsert = "";    //添加权限编码
        const string RightCodeUpdate = "";    //修改权限编码
        const string RightCodeDelete = "";    //删除权限编码

        const string ErrorCodeSelect = "";    //查询异常编码
        const string ErrorCodeInsert = "";    //添加异常编码
        const string ErrorCodeUpdate = "";    //修改异常编码
        const string ErrorCodeDelete = "";    //删除异常编码

        /// <summary>
        /// 根据ParameterID字段获取SysParametersInfo实体对象
        /// </summary>
        /// <param name="parameterID">ParameterID</param>
        /// <returns>SysParametersInfo实体对象</returns>
        public SysParametersInfo GetInfoById(string parameterID)
        {
            try
            {
                return new SysParametersDAL(loginInfo).GetInfoById(parameterID);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysParametersBLL", "GetInfo", AppError.EROR, 0, ex, "获取SysParameters信息出错。",
                                String.Format("parameterID = {0}", parameterID));
                throw new MDPException(ErrorCodeSelect, ex);
            }
        }

        /// <summary>
        /// 往SysParameters表内添加新记录
        /// </summary>
        /// <param>SysParametersInfo实体对象 <name>SysParametersInfo</name> </param>
        /// <param name="sysParametersInfo"> </param>
        /// <returns>添加记录索引值</returns>
        public int Insert(SysParametersInfo sysParametersInfo)
        {
            try
            {
                new SysParametersDAL(loginInfo).Insert(sysParametersInfo);
                const int identity = 1;
                return identity;
            }
            catch (Exception ex)
            {
                Logger.LogError("SysParametersBLL", "Insert", AppError.EROR, 0, ex, "添加SysParameters信息出错。", null);
                throw new MDPException(ErrorCodeInsert, ex);
            }
        }

        /// <summary>
        /// 更新SysParameters表记录
        /// </summary>
        public void Update(SysParametersInfo sysParametersInfo)
        {
            try
            {
                new SysParametersDAL(loginInfo).Update(sysParametersInfo);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysParametersBLL", "Update", AppError.EROR, 0, ex, "更新SysParameters信息出错。",
                                String.Format("ParameterID = {0}", sysParametersInfo.ParameterID));
                throw new MDPException(ErrorCodeUpdate, ex);
            }
        }

        /// <summary>
        /// 根据ParameterID字段获取SysParametersInfo实体对象
        /// </summary>
        /// <param name="parameterID">ParameterID</param>
        public void Delete(string parameterID)
        {
            try
            {
                new SysParametersDAL(loginInfo).Delete(parameterID);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysParametersBLL", "Delete", AppError.EROR, 0, ex, "删除SysParameters信息出错。",
                                String.Format("parameterID = {0}", parameterID));
                throw new MDPException(ErrorCodeDelete, ex);
            }
        }

        /// <summary>
        /// 根据ParameterID字段获取SysParametersInfo实体对象
        /// </summary>
        /// SqlParameter[] sqlparams
        /// <returns>SysParametersInfo实体对象列表</returns>
        public List<SysParametersInfo> GetInfoList(SqlParameter[] sqlparams = null)
        {
            try
            {
                return new SysParametersDAL(loginInfo).GetInfoList(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysParametersBLL", "GetInfoList", AppError.EROR, 0, ex, "获取SysParameters信息出错。",
                                String.Format("parameterID = {0}", ""));
                throw new MDPException(ErrorCodeSelect, ex);
            }
        }

        /// <summary>
        /// 根据ParameterID字段获取SysParametersInfo实体对象
        /// </summary>
        /// SqlParameter[] sqlparams
        /// <returns>SysParametersInfo实体对象列表</returns>
        public List<SysParametersInfo> GetInfoList(string parameterType)
        {
            try
            {
                return new SysParametersDAL(loginInfo).GetInfoList(parameterType);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysParametersBLL", "GetInfoList", AppError.EROR, 0, ex, "获取SysParameters信息出错。",
                                String.Format("parameterID = {0}", ""));
                throw new MDPException(ErrorCodeSelect, ex);
            }
        }

        /// <summary>
        /// 获取字段，首选默认，MyTexts做为value值
        /// </summary>
        /// <returns></returns>
        public SelectList GetInfoListByType(string parameterType)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(parameterType))
                {
                    var sl = new List<SelectList>();
                    return new SelectList(sl);
                }

                return new SelectList(new SysParametersDAL(loginInfo).GetInfoList(parameterType), "ParameterCode", "ParameterValue");
            }
            catch (Exception ex)
            {
                Logger.LogError("SysParametersBLL", "GetInfoListByType", AppError.EROR, 0, ex, "获取SysParameters信息出错。",
                                String.Format("parameterID = {0}", ""));
                throw new MDPException(ErrorCodeSelect, ex);
            }

        }

    }
}